package xg.glycomaid;
import java.net.URL;

import javax.swing.table.DefaultTableModel;


class OutputTableModel extends DefaultTableModel {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final ColumnContext[] columnArray = {
        new ColumnContext("MZ/Intensity",  String.class, false),
        new ColumnContext("Composition", String.class, false),
        new ColumnContext("IMZRE/ln(De)", String.class, false),
    	new ColumnContext("Confidence", String.class, false),
        new ColumnContext("CFG Link",  URL.class, false),
        new ColumnContext("Species Record in Link", String.class, false),
    };

    public void addOutputRow(OutputRow oc) {
        Object[] obj = {oc.getMzintString(), oc.getComposition(), oc.getMzintNormString(), oc.getConfidence(), oc.getURL(), oc.getSource()};
        super.addRow(obj);
    }
    
	@Override public boolean isCellEditable(int row, int col) {
        return columnArray[col].isEditable;
    }
    @Override public Class<?> getColumnClass(int modelIndex) {
        return columnArray[modelIndex].columnClass;
    }
    @Override public int getColumnCount() {
        return columnArray.length;
    }
    @Override public String getColumnName(int modelIndex) {
        return columnArray[modelIndex].columnName;
    }
    
    private static class ColumnContext {
        public final String  columnName;
        public final Class   columnClass;
        public final boolean isEditable;
        public ColumnContext(String columnName, Class columnClass, boolean isEditable) {
            this.columnName = columnName;
            this.columnClass = columnClass;
            this.isEditable = isEditable;
        }
    }
}